<?php


namespace App\Api\Repositories;


use App\Api\Models\CmcOrderList;

class OrderListRepositorie
{

    //获取订单列表
    public static function getAll($uid)
    {
        $data =  CmcOrderList::getList($uid);
        return self::orderType($data);
    }

    //订单分类
    public static function orderType($data)
    {
        $refund = [];       //申请退款
        $returnok = [];     //退货成功
        $refunded = [];     //已退款
        $pickedup = [];     //待取货
        $indelivery = [];   //配送中
        $received = [];     //已收货
        $evaluated = [];    //待评价
        foreach ($data as $item){
            switch ($item['status']){
                case -1:
                    $refund[] = $item;
                    break;
                case -2:
                    $returnok[] = $item;
                    break;
                case -3:
                    $refunded[] = $item;
                    break;
                case 0:
                    $pickedup[] = $item;
                    break;
                case 1:
                    $indelivery[] = $item;
                    break;
                case 2:
                    $received[] = $item;
                    break;
                case 3:
                    $evaluated[] = $item;
                    break;
            }
        }
        return ['all'=>$data,
                'refund'=>$refund,
                'returnok'=>$returnok,
                'refunded'=>$refunded,
                'pickedup'=>$pickedup,
                'indelivery'=>$indelivery,
                'received'=>$received,
                'evaluated'=>$evaluated
        ];
    }

}